# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4

inherit eutils multilib git-2

DESCRIPTION="libretro implementation of DeSmuME. (Nintendo DS)"
HOMEPAGE="https://github.com/libretro/desmume-libretro"
SRC_URI=""

EGIT_REPO_URI="git://github.com/libretro/desmume-libretro.git"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="+jit"

REQUIRED_USE="arm? ( !jit )"

RDEPEND=""

DEPEND=""

S="${WORKDIR}"

src_unpack() {
	S="${WORKDIR}" git-2_src_unpack
}

src_compile() {
	if use jit; then
		use amd64 && JIT="DESMUME_JIT=1"
		use x86 && JIT="DESMUME_JIT=1"
	fi
	
	emake -f Makefile.libretro \
		$JIT \
		|| die "emake failed"
}



src_install() {
        exeinto /usr/$(get_libdir)/libretro
        doexe *.so || die
}

pkg_postinst() {
	elog "There are various core options aviable."
	elog "They appear after first starting the core in your core_options_path."
}